<?php
declare (strict_types=1);

namespace app\api\validate;

use think\Validate;

class Exchange extends Validate
{
    protected $rule = [
        "account" => "require",
        "take_account" => "require",
        "amount" => "require|gt:0|checkInt"
    ];

    protected $message = [
        'account.require' => '请选择转出账户',
        'take_account.require' => '请选择转入账户',
        'amount.require' => '请填写转换金额',
        'amount.gt' => '转换金额有误',
        'amount.checkInt' => '转换金额必须为整数'
    ];

    protected function checkInt($value, $rule, $data = []): bool
    {
        return (string)(int)$value === $value;
    }
}